<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
        <link rel="stylesheet" type="text/css" th:href="@{/serve/layui/css/layui.css}"/>
        <link rel="stylesheet" type="text/css" th:href="@{/serve/css/admin.css}"/>
	</head>
	<body>
		<div class="wrap-container">
			<form class="layui-form" style="width: 90%;padding-top: 20px;">
					<div class="layui-form-item">
						<label class="layui-form-label">角色名称：</label>
						<div class="layui-input-block">
							<input type="text" name="roleName" required lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">角色Key：</label>
						<div class="layui-input-block">
							<input type="text" name="roleKey" required lay-verify="required" placeholder="请输入应用" autocomplete="off" class="layui-input">
						</div>

					</div>
					<div class="layui-form-item layui-form-text">
						<label class="layui-form-label">备注</label>
						<div class="layui-input-block">
							<textarea name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="role">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
		</div>
		<script th:src="@{/serve/layui/layui.js}" type="text/javascript" charset="utf-8"></script>
		<script>
            layui.config({
                base: './serve/js/module/'
            });
			//Demo
			layui.use(['form', 'jquery'], function() {
				var form = layui.form();
                var $ = layui.jquery;
				form.render();
				//监听提交
				form.on('submit(role)', function(data) {
					layer.msg(JSON.stringify(data.field));
					console.log(data.field)
                    $.ajax({
                        type: "POST",
                        contentType: "application/json;charset=UTF-8",
                        url: "/sys/role",
                        data: JSON.stringify(data.field),
                        dataType: 'json',
                        success: function(r) {
                            layer.msg(r.msg);
                            if(r.code ==100){
                                return true;
                            }
                        }
                    });
					return false;
				});
			});
		</script>
	</body>

</html>